
import unittest
import itertools

class TestIterTools(unittest.TestCase):
    """
    test the usage of itertool package
    """
    
    def test_repeat(self):
        repeater = itertools.repeat(10,3) 
        self.assertTrue(isinstance(repeater,itertools.repeat))
        
        alist = [x for x in repeater]
        self.assertEqual([10,10,10],alist)
        
    def test_chain(self):
        def generator1():
            yield 1
            yield 2
            
        def generator2():
            yield 3
            yield 4
            
        chained = itertools.chain(generator1(),generator2())
        self.assertEqual([1,2,3,4],[x for x in chained])

    
if __name__ == "__main__":
    unittest.main()